qui(function (require, exports, module) {
    VODNew.Util = $.extend(true, {}, EpgWeb.Util, {
        formatter: {
            operate_frame: function (cellvalue, options, rowObject) {
                return '<button type="button" class="btn btn-info" onclick="VODNew.Util.delFrame(' + rowObject.index + ')">删除</button>' +
                    '<button  type="button" class="btn" onclick="VODCom.Player.reviewOne(\'' + rowObject.sTime + '\',\'' + rowObject.eTime + '\',\'打点\');">预览</button>' +
                    '<button type="button" class="btn" onclick="VODNew.Util.fromLIstJump(' + rowObject.sTime + ');" >跳转</button>';
            },
            operate_advert: function (cellvalue, options, rowObject) {
                return '<button type="button" class="btn btn-info" onclick="VODNew.Util.delAdvert(' + rowObject.index + ')">删除</button>' +
                    '<button  type="button" class="btn" onclick="VODCom.Player.reviewOne(\'' + rowObject.sTime + '\',\'' + rowObject.eTime + '\',\'删除\');">预览</button>' +
                    '<button type="button" class="btn" onclick="VODNew.Util.fromLIstJump(' + rowObject.sTime + ');" >跳转</button>';
            },
            operate_mask: function (cellvalue, options, rowObject) {
                return  '<button type="button" class="btn btn-info" onclick="VODNew.MaskManager.modifyMaskEntity(' + rowObject.index + ')">修改</button>' +
                    '<button type="button" class="btn btn-info" onclick="VODNew.MaskManager.delMaskEntity(' + rowObject.index + ')">删除</button>';
            },
            news_title: function (cellvalue, options, rowObject) {
                if (cellvalue.length == 0) {
                    return "";
                }
                if (VODNew.Config.PageBeanNews == null) {
                    return "";
                }
                var findData = VODNew.Config.PageBeanNews.findData("regId", parseInt(rowObject.regId));
                if (findData.showTitle == null) {
                    var titleArr = JSON.parse(cellvalue);
                    if (titleArr.length == 0) {
                        findData.showTitle = "";
                    } else {
                        findData.showTitle = titleArr[0];
                    }
                }
                return '<div style="min-height: 20px;min-width: 100px" aria-describedby="myTitle">' + findData.showTitle + '</div><a style="text-underline-position: below;color:blue" onclick="VODNew.Util.AlterTitle(' + rowObject.regId + ' )">选择</a>'
            },
            title_news_del: function (cellvalue, options, rowObject) {
                var findData = VODNew.Config.PageBeanNewsDel.findData("regId", parseInt(rowObject.regId));
                return findData.showTitle;
            },
            title_news_submit: function (cellvalue, options, rowObject) {
                //      var findData = VODNew.Config.PageBeanNewsSubmit.findData("regId", parseInt(rowObject.regId));
                return cellvalue;
            },

            operate_news_merge: function (cellvalue, options, rowObject) {
                var ret = '<a style="cursor: pointer;color:blue;" onclick="VODNew.Util.viewNews(' + rowObject.regId + ')">预览</a>|' +
                    '<a style="cursor: pointer;color:blue" onclick="VODNew.Util.fillFormNews(' + rowObject.regId + ' )">导入</a>|' +
                    '<a style="cursor: pointer;color:blue" onclick="VODNew.Util.mockDelNews(' + rowObject.regId + ' )">删除</a>'
                if (rowObject.isMergeMode) {
                    ret += '|<br><a style="cursor: pointer;color:blue" onclick="VODNew.Util.undoMerge(' + rowObject.regId + ' )">撤销合并</a>';
                }
                return ret;
            },
            operate_merge_submit: function (cellvalue, options, rowObject) {
                var ret = '<a style="cursor: pointer;color:blue" onclick="VODCom.Player.reviewOne(' + rowObject.sTime + ',' + rowObject.eTime + ',\'打点\' )">预览</a>';
                return ret;
            },
            operate_merge_del: function (cellvalue, options, rowObject) {
                var ret = '<a style="cursor: pointer;color:blue" onclick="VODNew.Util.viewNewsDel(' + rowObject.regId + ' )">预览</a>|' +
                    '<a style="cursor: pointer;color:blue" onclick="VODNew.Util.cancelMergeDel(' + rowObject.regId + ' )">撤销删除</a>';
                return ret;
            },

            error_hint: function (cellvalue, options, rowObject) {
                return "";
            },
            news_id: function (cellvalue, options, rowObject) {
                var ret = "";
                ret = "<input type='checkbox' onclick='VODNew.Util.doRowSelected(this)' aria-describedby='checked'  value='@val' @checked  >".replace("@checked", (rowObject.checked ? "checked" : "")).replace("@val", cellvalue) + cellvalue
                return ret;
            },
            hidden_news_id: function (cellvalue, options, rowObject) {
                return rowObject.regId;
            },
            ad_inpoint: function (cellvalue, options, rowObject) {
                return  rowObject.sTime + ( rowObject.head != "" ? "(" + rowObject.head + " )" : "");
            },
            ad_outpoint: function (cellvalue, options, rowObject) {
                return  rowObject.eTime + ( rowObject.end != "" ? "(" + rowObject.end + " )" : "");
            }
        },

        getUrlParams: function () {
            // var queryStringArr = location.search.match(new RegExp("[\?\&][^\?\&]+=[^\?\&]+", "g")),
            var queryStringArr = decodeURIComponent(location.search).substring(1).split("&"),
                queryStringObj = {}
            var itemArr = [];
            try {
                if (queryStringArr != null) {
                    for (var i = 0; i < queryStringArr.length; i++) {
                        itemArr = queryStringArr[i].split("=");
                        if (i == 0) {
                            queryStringObj['channel_code'] = itemArr[0];
                            queryStringObj['ip'] = itemArr[1];
                        }
                        else {
                            queryStringObj[itemArr[0]] = itemArr[1];
                        }
                    }
                }
            }
            catch (e) {
                console.log("URL地址参数有误，请确认！")
                //  VODNew.Plugin.tips("error","URL地址参数有误，请确认！");
            }
            return queryStringObj;
        },
        LayoutInit: function () {
            $(".tab-content").css({
                height: VODNew.Util.getPageRelativeMesurement().height - 300 - 10 - 49 - 20 - 2
            });
            $("#makedImg").css({
                height: VODNew.Util.getPageRelativeMesurement().height - 90 - 2
            });
        },
        getUserAgent: function () {
            var ua = navigator.userAgent;

            var result = {
                isStrict: document.compatMode == "CSS1Compat",
                isGecko: /gecko/i.test(ua) && !/like gecko/i.test(ua),
                isWebkit: /webkit/i.test(ua)
            };

            try {
                if (/(\d+\.\d+)/.test(external.max_version)) {
                    result.maxthon = +RegExp['\x241'];
                }
            } catch (e) {
                console.log(e);
            }

            if (/msie (\d+\.\d+)/i.test(ua)) {
                result.ie = document.documentMode || +RegExp['\x241'];
            } else if (/trident(\.*?)/i.test(ua)) {
                result.ie = document.documentMode || +RegExp['\x241'];
            } else if (/chrome\/(\d+\.\d+)/i.test(ua)) {
                result.chrome = +RegExp['\x241'];
            } else if (/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(ua) && !/chrome/i.test(ua)) {
                result.safari = +(RegExp['\x241'] || RegExp['\x242']);
            } else if (/firefox\/(\d+\.\d+)/i.test(ua)) {
                result.firefox = +RegExp['\x241'];
            } else if (/opera(?:\/| )(\d+(?:\.\d+)?)(.+?(version\/(\d+(?:\.\d+)?)))?/i.test(ua)) {
                result.opera = +(RegExp["\x244"] || RegExp["\x241"]);
            }

            return result;
        },
        detectBrowserSupport: function (browser) {
            var support = false;
            if (browser.isWebkit || browser.firefox) {
                support = true;
            }
            if (browser.ie && browser.ie >= 9) {
                support = true;
            }
            if (!support) {
                var str = '警告！您使用的浏览器版本过低，为了获得更好使用体验。请使用Chrome、Firefox或IE10浏览器。谢谢！';
                VODNew.Plugin.tips("error", str);
            }

        },

        // 加载合作方信息
        setCooperativePartner: function (categoryName) {
            var self = this;
            $('#cp').html("");
            var videoTypeMinusOne = self.isVideoType1();
            if (videoTypeMinusOne) {
                return;
            }
            var channel_name = VODNew.Dao.getParamsData().channel_name;
            // 关联合作方信息
            VODNew.Dao.getCooperativePartner({
                'channeltype': categoryName,
                'channelalias': channel_name,
                'ptype': 'UGC',
                'pageNo': 0,
                'pageSize': 1000
            }, function (cps) {
                if (cps == undefined) {
                    return;
                }
                var cpStr = '<option uid="" partnerId="" episodeType="' + VODNew.Config.PGC + '"></option>';
                //     var i = 0,
                var selected = '';

                $.each(cps, function (i, item) {
                    if (channel_name === item.channelalias) {
                        cpStr += '<option uid="' + item.ugcid + '"  selected  partnerId="' + item.qipuid + '" episodeType="' + VODNew.Config.UGC + '">' + item.ugcmsg + '</option>';
                        return false;
                    }
                })
                $('#cp').html(cpStr);
            });
        },


        compareTime: function (beginTime, endTime) {

            var beginTimes = beginTime.substring(0, 10).split('-');
            var endTimes = endTime.substring(0, 10).split('-');

            beginTime = beginTimes[1] + '-' + beginTimes[2] + '-' + beginTimes[0] + ' ' + beginTime.substring(10, 19);
            endTime = endTimes[1] + '-' + endTimes[2] + '-' + endTimes[0] + ' ' + endTime.substring(10, 19);

            var a = (Date.parse(endTime) - Date.parse(beginTime)) / 3600 / 1000;
            if (a < 0) {
                return -1;
            } else if (a > 0) {
                return 1;
            } else if (a == 0) {
                return 0;
            } else {
                return 'exception'
            }
        },
        detectZoom: function () {
            var ratio = 0,
                screen = window.screen,
                ua = navigator.userAgent.toLowerCase();

            if (window.devicePixelRatio !== undefined) {
                ratio = window.devicePixelRatio;
            } else if (~ua.indexOf('msie')) {
                if (screen.deviceXDPI && screen.logicalXDPI) {
                    ratio = screen.deviceXDPI / screen.logicalXDPI;
                }
            } else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
                ratio = window.outerWidth / window.innerWidth;
            }

            if (ratio) {
                ratio = Math.round(ratio * 100);
            }

            return ratio;
        },
        browserZoomTips: function () {
            $('[role=alert1]').hide();
            if (VODNew.Util.detectZoom() > 100) {
                $('[role=alert]').html(VODNew.Config.ZOOM_HINT.BIG).show();
            } else if (VODNew.Util.detectZoom() < 100) {
                $('[role=alert]').html(VODNew.Config.ZOOM_HINT.SMALL).show();
            } else {
                $('[role=alert]').html("").hide();
            }
        },


        getPageRelativeMesurement: function () {
            return {
                width: $(window).width(),
                height: $(window).height()
            };
        },

        isJumpData: function (data, type) {
            if (type == 1) {
                var regJumpData = /^(\d{2}):(\d{2}):(\d{2})$/;
                if (!regJumpData.test(data)) {
                    return false;
                }
                return true;
            } else {
                if (isNaN(data)) {
                    return false;
                }
                return true;
            }
        },
        isVideoType1: function () {
            if ($('input[name=videotype]:checked').val() == -1)
                return 0;
            else
                return 1;
        },

        dealDirectionKey: function (arrow, settings) {
            if (!$(".red").is(":visible")) {
                return;
            }

            var currentTarget = parseInt($(".red").parent().find(".pid").text().replace(/\s+/g, ""));
            switch (arrow) {
                case  VODNew.Config.KEY_CODE.UP:
                    currentTarget = currentTarget - VODNew.Dao.settings.linePicNum;
                    break;
                case VODNew.Config.KEY_CODE.DOWN:
                    currentTarget = currentTarget + VODNew.Dao.settings.linePicNum;
                    break;
                case   VODNew.Config.KEY_CODE.LEFT:
                    currentTarget--;
                    break;
                case   VODNew.Config.KEY_CODE.RIGHT:
                    currentTarget++;
                    break;
            }
            if (currentTarget < 0) {
                currentTarget = 0;
            }
            $(".red").parent().find(".layout").removeClass("red").addClass("old");
            if (currentTarget >= parseInt($('#picNum').text())) {
                currentTarget = parseInt($('#picNum').text()) - 1;
            }
            settings.pic = settings.etime = settings.stime = currentTarget;
            var newTargetParent = $("#img-" + currentTarget).parent();
            if (newTargetParent.find(".layout").length > 0) {
                newTargetParent.find(".layout").addClass("red");
            } else {
                $(newTargetParent).append(VODNew.Config.RED_LAYOUT);
            }
            var offset = $(".red").offset();
            var heightLimit = $("#makedImg").height() - $(".red").height();
            if (offset.top < 22) {
                $("#makedImg").scrollTop(parseInt($("#makedImg").scrollTop() + offset.top - 22));
            }
            else if (offset.top > heightLimit) {
                $("#makedImg").scrollTop(parseInt($("#makedImg").scrollTop() + offset.top - heightLimit));
            }
        },
        setHighLight: function (rowData) {
            if (rowData != null) {
                var options = {};
                options.st = rowData.sTime
                options.et = rowData.eTime
                options.id = rowData.regId
                options.pic = rowData.pic
                VODCom.NewsHighlight.setHighLight(options);
            } else {
                VODCom.NewsHighlight.setHighLight(null);
            }
        },

        setMaskHighLight: function (rowData) {
            VODCom.NewsHighlight.clearMaskMark()
            if (rowData != null) {
                var options = {};
                if (rowData.sTime >= 0) {
                    options.maskST = rowData.sTime
                }
                if (rowData.eTime > 0) {
                    options.maskET = rowData.eTime
                }
                options.maskIndex = rowData.index
                VODCom.NewsHighlight.addInOutMaskMark(options)
            }
        },

        delFrame: function (rowId) {
            SystemDialog.queryConfirm("确认删除么?", function (flag) {
                if (flag === true) {
                    var findData = VODNew.Config.PageBeanFrame.findData("index", rowId);
                    if (findData != null) {
                        VODNew.Config.PageBeanFrame.delOne(findData)
                        VODNew.Util.updateGridFrame();
                    }
                }
            })
        },

        viewNews: function (rowId) {
            var findData = VODNew.Config.PageBeanNews.findData("regId", rowId);
            VODNew.Util.doReview(findData.sTime, findData.eTime, false)
        },

        viewNewsSubmit: function (rowId) {
            var findData = VODNew.Config.PageBeanNewsSubmit.findData("regId", rowId);
            if (findData == null) {
                console.log("no find data " + rowId);
                return;
            }
            VODNew.Util.doReview(findData.sTime, findData.eTime, false)
        },
        viewNewsDel: function (rowId) {
            var findData = VODNew.Config.PageBeanNewsDel.findData("regId", rowId);
            if (findData == null) {
                console.log("no find data " + rowId);
                return;
            }
            VODNew.Util.doReview(findData.sTime, findData.eTime, false)
        },


        delNews: function (rowId, skipQuery) {
            skipQuery = skipQuery === true ? true : false;
            var findData = VODNew.Config.PageBeanNews.findData("regId", rowId);
            var toRemoveArr = [];
            if (findData != null) {
                if (findData.isMergeMode) {
                    if (findData.toRemoveArr.length > 0) {
                        toRemoveArr = findData.toRemoveArr;
                    }
                } else if (findData.id > 0) {
                    toRemoveArr.push(findData.id);
                }
            }
            if (skipQuery) {
                VODNew.Util.delNewsMethod(toRemoveArr, findData);
            } else {
                SystemDialog.queryConfirm("确认删除该条新闻么?", function (flag) {
                    if (flag === true) {
                        VODNew.Util.delNewsMethod(toRemoveArr, findData);
                    }
                });
            }
        },
        delNewsMethod: function (toRemoveArr, findData) {
            VODNew.Dao.delNews({ key: VODNew.Dao.settings.taskid, id: toRemoveArr.join(","), status: 2, from_client: true }, function (data) {
                console.log(JSON.stringify(data));
                if (data.code == "A00000") {
                    VODNew.Plugin.tips("success", data.msg);
                    VODNew.Util.mockDelNews(findData.regId, true);
                } else {
                    VODNew.Plugin.tips("error", data.msg);
                }
            })
        },
        fillFormNews: function (rowId) {
            if (VODNew.Util.isAppendFragmentMode()) {
                return;
            }
            $(".ad-l").click();
            $(".ad-r").click();
            var findData = VODNew.Config.PageBeanNews.findData("regId", rowId);
            var panel = $("#cForm");
            panel.find("input[name=sTime]").val(findData.sTime);
            panel.find("input[name=eTime]").val(findData.eTime);
            panel.find("input[name=imageId]").val(findData.pic);
            panel.find("input[name=videoName]").val(findData.showTitle);
            panel.find("input[name=videoName]").change();
            this.recordImportData(rowId);
            //VODNew.Util.clearHighLight();
        },
        mockDelNews: function (rowId, skipAddToDelGrid) {
            var bdiv = $("#tab1").find(".ui-jqgrid-bdiv")
            var oldPosition = bdiv.scrollTop();
            var findData = VODNew.Config.PageBeanNews.findData("regId", rowId);
            VODNew.Config.PageBeanNews.delOne(findData);
            $("#news_list")[0].addJSONData(VODNew.Config.PageBeanNews.getCur());
            bdiv.scrollTop(oldPosition);
            if (skipAddToDelGrid == true) {
                return;
            }
            VODNew.Config.PageBeanNewsDel.addNewOne(findData);
            findData.index = VODNew.Dao.settings.newsDelIndex;
            VODNew.Dao.settings.newsDelIndex++;
            VODNew.Config.PageBeanNewsDel.sortData(VODNew.Config.SORT_RULE.desc_news_index)
            $("#auto_del_list")[0].addJSONData(VODNew.Config.PageBeanNewsDel.getCur());
            this.triggerNewsChange([rowId]);
        },
        cancelMergeDel: function (rowId) {
            var bdiv = $("#tab1").find(".ui-jqgrid-bdiv")
            var oldPosition = bdiv.scrollTop();
            var findData = VODNew.Config.PageBeanNewsDel.findData("regId", rowId);
            VODNew.Config.PageBeanNewsDel.delOne(findData);
            delete  findData.index;
            $("#auto_del_list")[0].addJSONData(VODNew.Config.PageBeanNewsDel.getCur());

            VODNew.Config.PageBeanNews.addNewOne(findData);
            VODNew.Config.PageBeanNews.sortData(VODNew.Config.SORT_RULE.asc_news_regId)
            $("#news_list")[0].addJSONData(VODNew.Config.PageBeanNews.getCur());
            bdiv.scrollTop(oldPosition);
        },
        delAdvert: function (rowId) {
            VODNew.Advert.delAdvert(rowId)
        },
        AlterTitle: function (rowId) {
            $("#alter_title-dlg").dialog("open");
            var rowData = VODNew.Config.PageBeanNews.findData("regId", rowId);
            var titleArr = JSON.parse(rowData.title);
            $("#alter_title-dlg").find("form").html("");
            var htmlArr = [];
            htmlArr.push('<input name="alter_title_id" type="hidden" value="' + rowId + '" />');
            $.each(titleArr, function (i, element) {
                htmlArr.push('<label><input type="radio" name="alter_title_radio" value="' + element + '" />' + element + '</label>')
            })
            $("#alter_title-dlg").find("form").html(htmlArr.join(""));
        },
        updateNewsGridRowData: function () {
            var selectedValue = $("input[name=alter_title_radio]:checked").val();
            if (selectedValue == null) {
                return;
            }
            var elementId = $("input[name=alter_title_id]").val();
            var rowData = VODNew.Config.PageBeanNews.findData("regId", elementId);
            if (rowData != null && rowData.showTitle != selectedValue) {
                rowData.showTitle = selectedValue;
                $("#news_list").setRowData(rowData.regId, { title: rowData.title, regId: rowData.regId });
            }
        },
        fromLIstJump: function (index) {
            if (!this.isJumpData(index, 0)) {
                //alert('跳转输入格式错误');
                VODNew.Plugin.tips("error", '跳转输入格式错误');
                return false;
            }
            var jumpContent = index + '-jump';
            if ($('.relative').hasClass(jumpContent)) {
                $('#makedImg').scrollTop(0)
                var sTop = $('.' + jumpContent).offset().top - 100;
                $('#makedImg').scrollTop(sTop);
            } else {
                //alert('没有这帧');
                VODNew.Plugin.tips("error", '没有这帧');
            }
        },
        initHelp: function () {
            var innerText = "";
            $.each(VODNew.Config.HELP_DATA, function (i, data) {
                innerText += '<tr><td>' + data[0] + '</td><td>' + data[1] + '</td></tr>'
            })
            $("#help-dlg").find("tbody").html(innerText);
            if ($("#help2-dlg").length > 0) {
                innerText = "";
                $.each(VODNew.Config.HELP2_DATA, function (i, data) {
                    innerText += '<tr><td>' + data[0] + '</td><td>' + data[1] + '</td></tr>'
                })
                $("#help2-dlg").find("tbody").html(innerText);
            }
        },
        validStart: function () {
            var self = this;
            var settings = VODNew.Dao.settings;
            if (VODNew.Config.EDIT_MODE_TYPE == 1) {
                var s_time = $('#inputStartTime').val();
                var e_time = $('#inputEndTime').val();
                var checkArr = [];
                checkArr.push({value: s_time.length, error: "请先输入起始时间", type: "gt", other: 0 })
                checkArr.push({value: e_time.length, error: "请先输入结束时间", type: "gt", other: 0 })
                checkArr.push({value: s_time, error: "起始时间格式不正确", type: "date"})
                checkArr.push({value: e_time, error: "结束时间格式不正确", type: "date"})
                checkArr.push({value: s_time, error: "开始时间必须小于结束时间", type: "lt", other: e_time })
                checkArr.push({value: s_time, error: "开始时间不能大于当前时间", type: "lt", other: this.formatDateTimeFormat(new Date()) });
                if (!VODNew.Plugin.Validate.batchCheck(checkArr)) {
                    console.log("interrupt checkLiveType checkRepeat")
                    return false;
                }
                settings.period = parseInt((self.dateToNumber(e_time) - self.dateToNumber(s_time)) / 1000);
                settings.today = s_time.replace(/-/g, '').substring(0, 8);
                settings.startQuery = parseInt(this.dateToNumber(s_time) / 1000);
                return   settings.startQuery;
            } else if (VODNew.Config.EDIT_MODE_TYPE == 2) {
                return true;
            }
            return false;

        },
        dateToNumber: function (dString) {
            var toDate = new Date(dString.replace(/-/g, "/"));
            return toDate.getTime();
        },
        getLineWidth: function () {
            var settings = VODNew.Dao.settings;
            var lineWidth = $('.img-content').width();
            var picWidth = $('.relative').width();
            settings.linePicNum = parseInt(lineWidth / picWidth);
        },
        dl_click: function (clt) {
            try {
                if (clt == '') {
                    return;
                }
                var Then = new Date();
                var continued_time = Math.round((Then.getTime()) / 1000);
                $.get(clt + "&ct=" + continued_time);
            }
            catch (e) {
                console.log("error", e);
            }
        },
        dl_img_click: function (event, viewTime) {
            var element = $(event.currentTarget);
            var options ={
                url:  element.attr("src").replace(/jpg/g, "flv"),
                name:    $(event.currentTarget).attr("id").replace("img-",""),
                duration :   element.attr("duration")
            }
            VODCom.Player.view(viewTime,options)
        },

        validAddInfo: function (data) {
            var v = true;
            $.each(data, function (message, type) {
                if (type == null || type.length == 0) {
                    VODNew.Plugin.tips("error", message + '不存在，请重新输入');
                    v = false;
                    return false;
                }
            });
            return v;
        },
        addInfo: function (data, type) {
            data.sTime = parseInt(data.sTime);
            data.eTime = parseInt(data.eTime);
            if (type == 'add') {
                $('#addInfo').html('成功');

                VODNew.Config.PageBeanFrame.addNewOne(data);
                VODNew.Util.updateGridFrame();
                this.notifyAddNewsSubmit(data);
            }
        },


        getDataByNum: function (period) {
            var second = period % 60;
            var minute = ( period % 3600 - period % 60) / 60;
            var hour = (period - period % 3600) / 3600;
            return (hour < 10 ? "0" + hour : hour) + ":" + (minute < 10 ? "0" + minute : minute) + ":" + (second < 10 ? "0" + second : second);
        },

        //提交删除
        checkStAndEt: function (stime, etime, plusMsg) {
            plusMsg = plusMsg || "";
            var checkArr = [];
            checkArr.push({value: stime, error: plusMsg + "起始帧有误,必须为数字类型", type: "number"})
            checkArr.push({value: etime, error: plusMsg + "结束帧有误,必须为数字类型", type: "number"})
            checkArr.push({value: parseInt(stime), error: plusMsg + "起始帧需要小于结束帧", type: "lt", other: parseInt(etime)  })
            return VODNew.Plugin.Validate.batchCheck(checkArr)
        },


        //提交拆条
        dot_submit: function () {
            var settings = VODNew.Dao.settings;
            VODNew.Config.LAST_SUBMIT_TIME = VODNew.Config.DOT_SUBMIT_TIME;
            VODNew.Config.DOT_SUBMIT_TIME = this.formatDateTimeFormat(new Date());
            var paramsData = VODNew.Dao.getParamsData();
            var global = VODNew.Config.Global;
            if (settings.taskid < 1.) {
                VODNew.Plugin.tips("error", '任务ID为空,不能提交!');
                return false;
            }
            if ($("span[span-mode=warn]").is(":visible")) {
                VODNew.Plugin.tips("error", '标题过长,不能提交!');
                return false;
            }
            var source = VODNew.Config.PageBeanMaskEntity.getSource();
            if (!VODNew.MaskManager.isValidDelogo(source)) {
                VODNew.Plugin.tips("error", '遮标数据出点入点都必须大于零，且入点不大于出点');
                return  false;
            }


            $('input[name=imageId]').val($('input[name=imageId]').val().trim());
            var sTime = $('input[name=sTime]').val(),
                eTime = $('input[name=eTime]').val(),
                title = $('input[name=videoName]').val(),
                channel = $('input[name=categoryName]').suggest("getValue");
            var cname = $('input[name=categoryName]').val();
            var cpOption = $('#cp').children('option:selected');
            var album = $('input[name=albumName]').val(),
                pic = $('input[name=imageId]').val() ? $('input[name=imageId]').val() : sTime,
                fantasyTitle = $('input[name=fantasyTitle]').val() ? $('input[name=fantasyTitle]').val() : "",
                data = {
                    '起始帧': sTime,
                    '结束帧': eTime,
                    '标题': title,
                    '频道': channel
                },
                dataSubmit = {
                    'index': settings.index,
                    'sTime': sTime,
                    'eTime': eTime,
                    'title': title,
                    'channel': channel,
                    'album': album,
                    'pic': pic
                }

            if (VODNew.Config.FORCE_CHECK_IMAGE.hasOwnProperty("tag" + channel)) {
                if ($('input[name=imageId]').val().length == 0) {
                    VODNew.Plugin.tips("error", "请人工选择封面图！");
                    return false;
                }
            }
            if (this.hasImportData()) {
                dataSubmit.importRegId = parseInt($("span[name=import-id-span]").attr("import-data-id"));
            }
            var toLego = true,
                priority = $('input[name=priority]:checked').val(), //优先级
                video_dpi = $('input[name=video_dpi]:checked').val(), //分辨率
                isVolumeStandard = $('input[name=isVolumeStandard]:checked').val(), //音量标准化参数
                isVolumeStandardForMaterial = $('input[name=isVolumeStandardForMaterial]:checked').val(),
                uid = cpOption.attr("uid"), //表示ugc用户id
                partnerId = cpOption.attr("partnerId"), //表示合作方id
                episodeType = cpOption.attr("episodeType"); //取值为0或1,1表示为ugc视频，0为普通ppc视频


            uid = !uid ? "" : uid;
            partnerId = !partnerId ? "" : partnerId;
            episodeType = !episodeType ? "" : episodeType;
            var albumId = '';
            if (album) {
                albumId = $('input[name=albumName]').suggest("getValue") || "";
                //  $('input[name=albumId]').val();
            }


            if (!this.checkStAndEt(sTime, eTime)) {
                return false;
            }
            if (VODNew.Util.isAppendFragmentMode()) {
                if (!VODNew.Util.checkFragmentEnd(eTime)) {
                    return false;
                }
            }
            var checkArr = [];
            checkArr.push({value: pic, error: "封面格式有误,必须为数字类型", type: "number"})
            checkArr.push({value: parseInt(pic), error: "封面不能小于起始帧", type: "ge", other: parseInt(sTime)});
            checkArr.push({value: parseInt(pic), error: "封面不能大于结束帧", type: "le", other: parseInt(eTime)})
            var numTime = $('#picNum').text();
            checkArr.push({value: parseInt(eTime), error: "结束帧不存在,不能提交", type: "lt", other: parseInt(numTime)  })
            if (!VODNew.Plugin.Validate.batchCheck(checkArr)) {
                console.log("interrupt checkLiveType checkRepeat")
                return false;
            }
            $('#addInfo').attr('disabled', 'disabled');
            if (!toLego) {
                return;
            }
            if (!this.validAddInfo(data)) {
                return false;
            }
            var needMark = true;
            if (this.hasImportData()) {
                var importData = VODNew.Config.PageBeanNews.findData("regId", parseInt($("span[name=import-id-span]").attr("import-data-id")))
                if (parseInt(dataSubmit.eTime) == importData.eTime) {
                    needMark = false;
                }
            }
            if (needMark) {
                var aframeData = VODNew.AccurateFrame.getAccurateFrame();
                if (aframeData.endSetted && aframeData.endPic == parseInt(dataSubmit.eTime)) {
                    needMark = false;
                }
            }
            if (needMark) {
                //alert("请在片尾使用精确化裁剪工具，快捷键Q");
                VODNew.Plugin.tips("error", "请在出点使用精确化裁剪工具，快捷键Q");
                return false;
            }

            //去除删除部分
            VODCom.Player.splitData(sTime, eTime, true);
            console.log(settings.subData);
            if (!settings.subData.length) {
                //alert('该条打了删除，不能再打拆条!');
                VODNew.Plugin.tips("error", '该条打了删除，不能再打拆条!');
                return false;
            }
            //未制作成片节目
            //提交数据到乐高
            // var p_vid = $('input[name=videoId]').val() ? $('input[name=videoId]').val() : 0;
            var p_vid = $('input[name=videoName]').suggest("getValue") || 0;
            var p_albumId = $('input[name=albumName]').suggest("getValue") || "";
            var videotype = $('input[name=videotype]:checked').val();
            if (videotype == -1) {
                p_vid = 0;
                var bind_sel_name = $('input[name=categoryName]').attr("bind-sel-name");
                var bind_sel_id = $('input[name=categoryName]').attr("bind-sel-id");
                if (bind_sel_name == null || bind_sel_name == "" || cname != bind_sel_name) {
                    VODNew.Plugin.tips("error", '提交失败，频道不存在!');
                    return false;
                }
            } else if (videotype == 0 || videotype == 1) {
                var bind_sel_name = $('input[name=videoName]').attr("bind-sel-name");
                var bind_sel_id = $('input[name=videoName]').attr("bind-sel-id");
                if (bind_sel_name == null || bind_sel_name == "" || title != bind_sel_name) {
                    VODNew.Plugin.tips("error", '提交失败，标题不存在!');
                    return false;
                }
            }

            var dadianmerge = {ocr_flag: 0, intelligent_insert_time: ""};
            if (this.hasImportData()) {
                dadianmerge.ocr_flag = 1;
                dadianmerge.intelligent_insert_time = $("span[name=import-id-span]").attr("import-data-time");
            } else {
                dadianmerge.intelligent_insert_time = VODNew.Config.LAST_SUBMIT_TIME;
            }

            if (VODNew.Config.fragmentPid > 0) {
                p_vid = VODNew.Config.fragmentPid;
                if (!this.hasImportData()) {
                    dadianmerge.intelligent_insert_time = VODNew.Config.FIRST_FRAGMENT_START;
                }
            }

            var handlerPostData = function (programId) {
                var newPA = {
                    title: title,
                    cat: channel,
                    alb: albumId,
                    enableClound: VODNew.Util.getEnableCloundVal(),
                    priority: priority,
                    video_dpi: video_dpi,
                    uid: uid,
                    partnerId: partnerId,
                    episodeType: episodeType
                }
                if (videotype == -1) {
                    newPA.fantasyTitle = fantasyTitle;
                } else if (videotype == 1) {
                    newPA.reTranscodeConfirm = VODNew.Util.getReTranscodeConfirmVal();
                }

                VODNew.Util.postData(settings.subData, newPA, pic, programId, dataSubmit, function (flag) {
                    //提交数据给刘之红
                    if (flag) {
                        var stData = $.extend(true, {}, dataSubmit, { programId: programId, cname: cname })
                        //     VODNew.Util.doSt1Data(advertParams.delAdStr, stData, dadianmerge);
                        VODNew.Util.doSt1Data(0, stData, dadianmerge);// 不使用 advertParams.delAdStr
                        VODNew.Config.OCR_TITLE_FLAG = 0;
                        VODCom.AutoTitle.clearData();
                        VODNew.Util.doSt2Data(stData);
                        //alert('打点成功');
                        VODNew.Plugin.tips("success", '打点成功');
                        VODNew.AccurateFrame.fgTipRemove();
                        VODNew.MaskManager.clearMaskEntity();
                        VODNew.AccurateFrame.adTipRemove();
                        console.log("[handlerPostData] handler suc")
                    } else {
                        console.log("[handlerPostData] handler fail")
                    }
                });
            }

            // dealroute 针对是否需要申请 programId
            var dealRoute = -1; //分片未提交
            if (VODNew.Config.lastLegoSubmitObj.programId != VODNew.Config.fragmentPid) {
                VODNew.Config.lastLegoSubmitObj.programId = VODNew.Config.fragmentPid;
                VODNew.Config.lastLegoSubmitObj.hasSubmit = false;
                dealRoute = 1;
            } else if (VODNew.Config.lastLegoSubmitObj.hasSubmit == false) {
                dealRoute = 2; // 如果 尚未提交过
            } else {
                dealRoute = 3; //  分片提交过
            }

            if (dealRoute == 1 || dealRoute == 2) {
                var dataJson = {
                    'videoId': p_vid,
                    'priority': priority,
                    'albumName': album,
                    'videoName': title,
                    'categoryId': channel,
                    'albumId': p_albumId,
                    'reTranscodeConfirm': VODNew.Util.getReTranscodeConfirmVal(),
                    'freeType': paramsData.freeType,
                    'isVolumeStandard': isVolumeStandard,
                    isVolumeStandardForMaterial: isVolumeStandardForMaterial,
                    userArea: VODNew.Util.getUserRegion()
                };
                if ($("#locationDiv").is(":visible")) {
                    dataJson.locationCategory = $("input[name=location]").suggest("getValue");
                }
                if (videotype == -1) {
                    dataJson.fantasyTitle = fantasyTitle;
                }
                // settings.videonameArr = [];

                var sendData = {"request": JSON.stringify({url: VODNew.Constant.thirdUrl_peditor_submit, type: "post", params: {
                    data: JSON.stringify(dataJson)
                }, needCookie: true}), timeSign: new Date().getTime()}
                VODNew.Dao.dopeditorSubmit(sendData, {
                    doSuc: function (res) {
                        if (res == null || res.code != 'A00000') {
                            VODNew.Util.logSubmit(VODNew.Config.VOD_LOG_TYPE.sendProgramDataToLego, sendData, res, "fromUrl:" + VODNew.Constant.thirdUrl_peditor_submit);
                            VODNew.Plugin.tips("error", res == null ? "lego接口无效返回值" : "lego错误：" + res.msg);
                            if (VODNew.Util.isAppendFragmentMode()) {
                                $('input[name=isAppendFragment]').removeAttr("disabled");
                                $('input[name=isAppendFragment][value="0"]').click();
                                //     VODNew.Util.transToNormalMode();
                            }
                        } else {

                            var programId = res.data.programId;
                            if (!programId) {
                                VODNew.Util.logSubmit(VODNew.Config.VOD_LOG_TYPE.sendProgramDataToLego, sendData, {error: '乐高返回的programId为空!'}, "fromUrl:" + VODNew.Constant.thirdUrl_peditor_submit);
                                //alert('乐高返回的programId为空!');
                                VODNew.Plugin.tips("error", '乐高返回的programId为空!');
                                return false;
                            }
                            VODNew.Util.episodeLogSubmit(programId, VODNew.Config.VOD_LOG_TYPE.sendProgramDataToLego, sendData, res, "fromUrl:" + VODNew.Constant.thirdUrl_peditor_submit);
                            VODNew.Config.fragmentPid = programId;
                            VODNew.Config.lastLegoSubmitObj.programId = VODNew.Config.fragmentPid;
                            VODNew.Config.lastLegoSubmitObj.hasSubmit = true;
                            handlerPostData(programId)
                        }
                    },
                    doError: function (XMLHttpRequest, status) {
                        VODNew.Util.logSubmit(VODNew.Config.VOD_LOG_TYPE.sendProgramDataToLego, dataJson, { type: "error reqeust", status: status }, "fromUrl:" + VODNew.Constant.thirdUrl_peditor_submit);
                        VODNew.Plugin.tips("error", '网络错误,请稍后再提交！');
                        //              VODNew.Plugin.tips("error", '接口/peditor/submit调用超时10秒未响应！请联系乐高相关负责人员！');
                    }
                })
            } else if (dealRoute == 3) {
                handlerPostData(p_vid)
            }
        },

        // 获取字符串长度
        subCharacterLength: function (str, charLength) {
            var titleReg = new RegExp("[\\u4E00-\\u9FFF]");
            var countLength = 0;
            var indexCount = 0;
            var tmpLength = 0;
            for (var i = 0, l = str.length; i < l; i++) {
                // 0-127 ASCII char
                // 128-255 ASCII expand char
                if (str.charCodeAt(i) > 255) {
                    tmpLength = 2;
                } else {
                    tmpLength = 1;
                }
                if (countLength + tmpLength > charLength) {
                    break;
                }
                indexCount++;
                countLength += tmpLength;
            }
            return str.substr(0, indexCount);
        },

        // 填加背景色
        addBackgroundColor: function (options) {
            var defaults = {
                st: 0,
                et: 0,
                color: '',
                removeColor: ''
            };
            options = $.extend({}, defaults, options);

            for (var i = options.st; i <= options.et; i++) {
                if (!options.removeColor) {
                    $('#img-' + i).addClass(options.color);
                } else {
                    $('#img-' + i).removeClass(options.color);
                }
            }
        },

        fetchDelogoArr: function (list) {
            //   return VODNew.MaskManager.getPicDropList(list[0], list[list.length -1]);
            var source = VODNew.MaskManager.makeUpSubDelogoArr();
            var subList = list;
            var retArr = [];
            var ableElement = null;
            $.each(source, function (i, element) {
                ableElement = VODNew.Util.filterEnableDelogo(element, subList);
                if (ableElement != null) {
                    retArr.push(ableElement);
                }
            })
            return retArr;
        },
        filterEnableDelogo: function (element, subList) {
            var min = subList[0];
            var max = subList[subList.length - 1];
            var finalObj = {st: element.st, et: element.et, coverArr: element.coverArr };
            while (subList.indexOf(finalObj.st) == -1) {
                finalObj.st++;
                if (finalObj.et != -1 && finalObj.st > finalObj.et) {
                    return null;
                }
                if (finalObj.st > max) {
                    return null;
                }
            }
            if(finalObj.et != -1){
                while (subList.indexOf(finalObj.et) == -1) {
                    finalObj.et--;
                    if (finalObj.et < finalObj.st) {
                        return null;
                    }
                    if (finalObj.et < min) {
                        return null;
                    }
                }
            }
            console.log("finalObj st:" + finalObj.st, ",et:" + finalObj.et + "|| element st:" + element.st + ",et" + element.et);
            return finalObj;
        },

        postData: function (list, newPA, imageId, programId, addData, handler) {
            var sList = '[' + list.join(",") + "]";
            var paramsData = VODNew.Dao.getParamsData();
            var settings = VODNew.Dao.settings;
            var accurateFrame = VODNew.AccurateFrame.getAccurateFrame();
            var dotData = VODNew.Dao.getDotData();
            var pData = {
                'title': newPA.title,
                'categoryId': newPA.cat,
                'albumId': newPA.alb,
                'code': paramsData.channel_name,
                'programId': programId,
                'userId': VODNew.Util.getUserId() + "",
                'from_client': true,
                'key': settings.taskid,
                'list': sList,
                'imageId': imageId,
                'head': accurateFrame.head,
                'end': accurateFrame.end,
                'priority': newPA.priority,
                'video_dpi': newPA.video_dpi,
                'uid': newPA.uid,
                'partnerId': newPA.partnerId,
                'episodeType': newPA.episodeType,
                'enableClound': newPA.enableClound,
                'needRemakeVideo': VODNew.Util.getNeedRemakeVideo(),
                'delogoArr': JSON.stringify(VODNew.Util.fetchDelogoArr(list))
            };

            if ("fantasyTitle" in newPA) {
                pData.fantasyTitle = newPA.fantasyTitle;
            }
            if ("reTranscodeConfirm" in newPA) {
                if (VODNew.Config.lastSubmitObj.programId != programId || VODNew.Config.lastSubmitObj.hasSubmit == false) {
                    VODNew.Config.lastSubmitObj.programId = programId;
                    VODNew.Config.lastSubmitObj.hasSubmit = true;
                    pData.reTranscodeConfirm = newPA.reTranscodeConfirm;
                }
            }

            var appendMode = VODNew.Util.isAppendFragmentMode();
            if (appendMode) {
                pData.tag = 1;
            }

            VODNew.AccurateFrame.doReset();
            var sendUrl = !appendMode ? dotData.dotUrl : dotData.appendUrl;
//            var hackData = $.extend(true,{},pData);
//            hackData.list = [-1].concat(     hackData.list );
            VODNew.Dao.postSync(sendUrl, pData, {
                doSuc: function (data) {
                    VODNew.Util.episodeLogSubmit(programId, VODNew.Config.VOD_LOG_TYPE.submitDotData, pData, data, "url:" + sendUrl);
                    if (data == null || data.error != 0) {
                        VODNew.Plugin.tips("error", data == null ? "提交打点无效返回值" : "提交打点错误:" + data.error);
                        handler(true);
                    } else {
                        VODNew.Config.lastSubmitObj = { programId: -1, hasSubmit: false}
                        VODNew.Config.lastLegoSubmitObj = { programId: -1, hasSubmit: false}
                        VODNew.Config.fragmentPid = 0;
                        VODNew.Util.doResetCForm("saveCategoryName");
                        VODNew.Util.setHighLight(null);
                        $('#addInfo').html('成功');
                        VODNew.Util.addInfo(addData, 'add');
                        settings.index++;
                        handler(true);
                    }
                },
                doError: function () {
                    VODNew.Util.episodeLogSubmit(programId, VODNew.Config.VOD_LOG_TYPE.submitDotData, pData, {type: "request error"}, "url:" + sendUrl);
                    VODNew.Plugin.tips("error", '编码服务器网络错误,请稍后再提交！');
                    $('#addInfo').removeAttr('disabled').html('提交');
                    handler(false);
                }
            }, false)
//                    VODNew.Util.logSubmit(VODNew.Config.VOD_LOG_TYPE.submitDotData, pData, {type: "request error"}, "url:" + sendUrl);
//                    VODNew.Plugin.tips("error", '编码服务器网络错误,请稍后再提交！');
//                    $('#addInfo').removeAttr('disabled').html('提交');
//                    handler(true);
        },


        doReview: function (sTime, eTime, deleteFlag) {
            var data = {
                '起始帧': sTime,
                '结束帧': eTime
            };
            if (!VODNew.Util.validAddInfo(data)) {
                return false;
            }
            if (parseInt(sTime) > parseInt(eTime)) {
                VODNew.Plugin.tips("error", '起始帧不能大于结束帧');
                return false;
            }
            var numTime = $('#picNum').text();
            if (parseInt(eTime) >= parseInt(numTime)) {
                VODNew.Plugin.tips("error", '结束帧不存在,不能预览');
                return false;
            }
            VODCom.Player.splitData(sTime, eTime, deleteFlag); //去除删除部分
            VODCom.Player.review();
        },

        getReTranscodeConfirmVal: function () {
            return  $('input[name=reTranscodeConfirm]').is(":checked") ? 1 : 0
        },
        getEnableCloundVal: function () {
            return  $('input[name=enableClound]').is(":checked") ? 0 : 1
        },
        getUserId: function () {
            return auth.baseInfo.authInfo.uid;
        },
        getUserName: function () {
            return auth.baseInfo.authInfo.userName;
        },

        /**
         * 限制输入框中字符个数，一个汉字相当于两个字符，wordCount是最多允许的汉字个数
         * @param  {jquery  object}  $des  限制字符个数的输入框
         * @param  {Number}  wordCount     允许输入的最多字字符数（一个汉字等于两个字符）
         * @param  {Boolean} isFilterChars 是否过滤输入内容，true过滤，false或undefined不过滤
         * @param  {Array}  filterChars    需要过滤的字符集，如['$','.']，意为全局过滤 $ *                                 和 .
         */
        limitWordCount: function ($des, charCount, isFilterChars, filterChars, bindHandler) {
            var self = this;
            charCount = charCount || 450;
            var t = function (textarea) {
                var $textarea = $(textarea);
                var text = $textarea.val();
                if (isFilterChars) {
                    text = Com.string.filterSpecialChars(text, filterChars);
                    $textarea.val(text);
                }
                var length = Com.string.getStrLength(text);
                if (length > charCount) {
                    $textarea.val(self.subCharacterLength(text, charCount));
                }
                text = $textarea.val();
                length = Com.string.getStrLength(text);
                if (bindHandler == null) {
                    $textarea.parent().find('span.leftWordsCount').text(charCount - length);
                } else {
                    bindHandler(charCount - length);
                }
            };
            $des.bind({
                input: function () {
                    //   console.log("input handler ")
                    t(this);
                },
                propertychange: function () {
                    t(this);
                },
                change: function () {
                    t(this);
                },
                focusout: function () {
                    setTimeout(function () {
                        t($des)
                    }, 100);
                },
                keyup: function () {
                    t(this);
                }
            });
            $des.keyup();
        },


        /**
         * 限制输入框中字符个数，一个汉字相当于两个字符，wordCount是最多允许的汉字个数
         * @param  {jquery  object}  $des  限制字符个数的输入框
         * @param  {Number}  wordCount     允许输入的最多字字符数（一个汉字等于两个字符）
         * @param  {Boolean} isFilterChars 是否过滤输入内容，true过滤，false或undefined不过滤
         * @param  {Array}  filterChars    需要过滤的字符集，如['$','.']，意为全局过滤 $ *                                 和 .
         */
        canOverWordCount: function ($des, charCount, isFilterChars, filterChars, bindHandler) {
            var self = this;
            charCount = charCount || 450;
            var t = function (textarea) {
                var $textarea = $(textarea);
                var text = $textarea.val();
                if (isFilterChars) {
                    text = Com.string.filterSpecialChars(text, filterChars);
                    $textarea.val(text);
                }
                var length = Com.string.getStrLength(text);
                if (bindHandler != null) {
                    bindHandler(charCount - length);
                }
            };
            $des.bind({
                input: function () {
                    t(this);
                },
                propertychange: function () {
                    t(this);
                },
                change: function () {
                    t(this);
                },
                focusout: function () {
                    setTimeout(function () {
                        t($des)
                    }, 100);
                },
                keyup: function () {
                    t(this);
                }
            });
            $des.keyup();
        },

        binSearchOcrTitle: function (start, end) {
            return this.binSearchTitle(VODNew.Dao.settings.g_ocrList, start, end)
        },
        binSearchAcrTitle: function (start, end) {
            return this.binSearchTitle(VODNew.Dao.settings.g_acrList, start, end)
        },
        binSearchTitle: function (arr, start, end) {
            var titleList = [];
            var tmp = [];
            var len = arr.length;
            if (len) {
                for (var i in arr) {
                    if (start >= arr[i]['first'] && start <= arr[i]['last'] || arr[i]['first'] >= start && arr[i]['last'] <= end || end >= arr[i]['first'] && end <= arr[i]['last']) {
                        tmp[arr[i]['title']] = i; // 去重复
                    }
                }
                for (var j in tmp) {
                    titleList.push(j);
                }
            }
            return titleList;
        },
        updateGridAdvert: function () {
            $('#advert_list').clearGridData();
            $('#advert_list')[0].addJSONData(VODNew.Config.PageBeanAdvert.getCur())
        },
        updateGridFrame: function () {
            $('#frame_list').clearGridData();
            $('#frame_list')[0].addJSONData(VODNew.Config.PageBeanFrame.getCur())
        },
        updateGridNewsSubmit: function () {
            $('#auto_submit_list').clearGridData();
            $('#auto_submit_list')[0].addJSONData(VODNew.Config.PageBeanNewsSubmit.getCur())
        },

        updateGridNewsDel: function () {
            $('#auto_del_list').clearGridData();
            $('#auto_del_list')[0].addJSONData(VODNew.Config.PageBeanNewsDel.getCur())
        },
        updateGridMaskEntity: function () {
            $('#mask_list').clearGridData();
            $('#mask_list')[0].addJSONData(VODNew.Config.PageBeanMaskEntity.getCur())
        },
        updateCForm: function (updateObj) {
            if (updateObj.hasOwnProperty("eTime")) {
                $("#cForm").find("input[name=eTime]").val(updateObj.eTime)
            }
            if (updateObj.hasOwnProperty("sTime")) {
                $("#cForm").find("input[name=sTime]").val(updateObj.sTime)
            }
            if (updateObj.hasOwnProperty("pic")) {
                $("#cForm").find("input[name=imageId]").val(updateObj.pic)
            }
        },
        updateObjectData: function (newData, oldData) {
            for (var key in newData) {
                if (oldData.hasOwnProperty(key)) {
                    oldData[key] = newData[key];
                }
            }
        },


        doRowSelected: function (element) {
            var tempChild = VODNew.Config.PageBeanNews.findData("regId", parseInt(element.value));
            tempChild.checked = $(element).is(":checked");
        },
        doSelectedAll: function (flag) {
            var elementArr = $("#news_list").find("input[type=checkbox]");
            $.each(elementArr, function (i, element) {
                if ($(element).is(":checked") == !flag) {
                    $(element).click();
                }
            })
        },

        doQuickMerge: function () {
            var selElementArr = $("#news_list").find("input[type=checkbox]:checked");
            var childArr = [];
            var tempChild = null;
            $.each(selElementArr, function (i, elem) {
                tempChild = VODNew.Config.PageBeanNews.findData("regId", parseInt(elem.value));
                childArr.push(tempChild);
            })
            childArr.sort(VODNew.Config.SORT_RULE.asc_news_sTime);
            if (childArr.length == 1) {
                return;
            }
            var checkContinue = -1;
            var toRemoveArr = [];
            var newTitleArr = [];
            var childTitleArr = null;
            var endFrameData = null;
            $.each(childArr, function (i, tempChild) {
                if (checkContinue == -1) {
                    checkContinue = tempChild.eTime;
                    endFrameData = tempChild.frameData;
                } else if (checkContinue + 1 >= tempChild.sTime) {
                    if (checkContinue < tempChild.eTime) {
                        checkContinue = tempChild.eTime;
                        endFrameData = tempChild.frameData;
                    } else if (endFrameData == null) {
                        endFrameData = tempChild.frameData;
                    } else {
                        if (tempChild.frameData != null && tempChild.frameData.end != endFrameData.end) {
                            console.log("结尾关键帧不同，清空")
                            endFrameData = null;
                        }
                    }
                } else {
                    VODNew.Plugin.tips("error", "条目不连续，不能合并");
                    checkContinue = -2;
                    return false
                }
                if (tempChild.id > 0) {
                    toRemoveArr.push(tempChild.id);
                } else if (tempChild.isMergeMode) {
                    toRemoveArr = toRemoveArr.concat(tempChild.toRemoveArr);
                }
                childTitleArr = JSON.parse(tempChild.title);

                if (childTitleArr.length > 0) {
                    if (tempChild.showTitle != "") {
                        if (childTitleArr.indexOf(tempChild.showTitle) == -1) {
                            childTitleArr = [ tempChild.showTitle ].concat(childTitleArr);
                        }
                    }
                    newTitleArr = newTitleArr.concat(childTitleArr);
                } else {
                    if (tempChild.showTitle != "") {
                        newTitleArr.push(tempChild.showTitle);
                    }
                }
            });
            if (checkContinue > 0) {
                var firstData = childArr[0];
                var newObj = {title: JSON.stringify(newTitleArr), sTime: firstData.sTime, eTime: checkContinue,
                    pic: firstData.pic, regId: firstData.regId, id: 0,
                    isMergeMode: true, children: childArr, toRemoveArr: toRemoveArr,
                    frameData: endFrameData
                };
                $("#news_list").clearGridData();
                VODNew.Util.mergeNewsGridData([newObj], childArr)
                VODNew.Util.setHighLight(newObj);
                VODNew.Util.fromLIstJump(newObj.sTime);
                VODNew.Util.doNewsGridScroll(newObj.regId);
                $("#news_list").jqGrid('setSelection', newObj.regId);
            }
        },
        doChangeTitle: function (element) {
            var $target = $(element);
            var targetId = null;
            targetId = parseInt($target.attr("data-id"))
            var rowData = VODNew.Config.PageBeanNews.findData("regId", targetId);
            rowData.showTitle = $target.val();
            $("#news_list").setRowData(rowData.regId, { title: rowData.title, regId: rowData.regId });
        },
        undoMerge: function (mergeId) {
            var rowData = VODNew.Config.PageBeanNews.findData("regId", parseInt(mergeId));
            $.each(rowData.children, function (i, element) {
                element.checked = false;
            })
            VODNew.Util.mergeNewsGridData(rowData.children, [rowData])
            VODNew.Util.clearHighLight();
            VODNew.Util.doNewsGridScroll(mergeId);

        },
        mergeNewsGridData: function (addArr, delArr) {
            var notifyArr = [];
            $.each(delArr, function (i, element) {
                VODNew.Config.PageBeanNews.delOne(element);
                notifyArr.push(element.regId);
            })
            $.each(addArr, function (i, element) {
                VODNew.Config.PageBeanNews.addNewOne(element);
            })
            VODNew.Config.PageBeanNews.sortData(VODNew.Config.SORT_RULE.asc_news_regId);
            $("#news_list")[0].addJSONData(VODNew.Config.PageBeanNews.getCur());
            VODNew.Util.triggerNewsChange(notifyArr);
        },
        clearHighLight: function () {
            VODCom.NewsHighlight.setHighLight(null);
        },
        doNewsGridScroll: function (rowid) {
            var bdiv = $("#tab1").find(".ui-jqgrid-bdiv");
            if (bdiv[0].scrollHeight <= bdiv[0].clientHeight) {
                return;
            }
            rowid = rowid + ""
            var allData = $("#news_list").jqGrid("getRowData");
            var interrupt = 0;
            for (var i = 0; i < allData.length; i++) {
                if (allData[i].hidden_news_id == rowid) {
                    interrupt = i;
                    break;
                }
            }
            bdiv.scrollTop(interrupt / allData.length * bdiv[0].scrollHeight);
        },
        hasIntelligentData: function () {
            $("#contains_news_list").show();
            $("hr:eq(0)").show();
        },
        nonIntelligentData: function () {
            $("#contains_news_list").hide();
            $("hr:eq(0)").hide()
        },
        doResetCForm: function (mode) {

            var saveData = null;
            if (mode == "saveCategoryName") {
                saveData = {};
                saveData.id = parseInt($('input[name=categoryName]').suggest("getValue"));
                saveData.label = $('input[name=categoryName]').val();
            }
            var locationVal = $("input[name=location]").val();
            $("#cForm")[0].reset();
            if (saveData != null) {
                $('input[name=categoryName]').suggest("setValue", saveData);
            }
            $('input[name=videoName]').suggest("setValue", "");
            $("input[name=albumName]").suggest("setValue", "");
            $("input[name=location]").val(locationVal);
            this.doClearImportData();
            $("input[name=videoName]").change();
            $("input[name=fantasyTitle]").change();
            $("#locationDiv").hide();
            $("input[name=videotype][value='-1']").click();
            $("input[name=isAppendFragment][value='0']").click()
        },

        doClearImportData: function (clearMode) {
            if (clearMode != null && clearMode == "all") {
                this.doResetCForm();
            } else {
                $("div[import-id-div=true]").hide();
                $("span[name=import-id-span]").html("");
                $("span[name=import-id-span]").removeAttr("import-data-id");
                $("span[name=import-id-span]").removeAttr("import-data-time");
            }
        },
        doResetDForm: function () {
            $("#dForm")[0].reset();
        },
        clearOldTaskData: function () {
            VODNew.Util.nonIntelligentData();
            VODNew.Config.PageBeanNews.setNewData([], 100);
            VODNew.Util.doResetCForm();
            VODCom.AutoTitle.clearData()
        },
        recordImportData: function (rowId) {
            $("div[import-id-div=true]").show();
            $("span[name=import-id-span]").html(rowId);
            $("span[name=import-id-span]").attr("import-data-id", rowId);
            $("span[name=import-id-span]").attr("import-data-time", this.formatDateTimeFormat(new Date()));
        },
        triggerNewsChange: function (targetArr) {
            if (targetArr.length > 0 && this.hasImportData()) {
                var elementId = $("span[name=import-id-span]").attr("import-data-id");
                if (targetArr.indexOf(parseInt(elementId)) != -1) {
                    console.log(" triggerNewsChange " + elementId)
                    this.doResetCForm();
                }
            }
        },
        notifyAddNewsSubmit: function (data) {
            if (data.importRegId && data.importRegId > 0) {
                var ocrFlagData = $.extend(true, {}, data);
                ocrFlagData.index = VODNew.Dao.settings.newsSubmitIndex;
                VODNew.Dao.settings.newsSubmitIndex++;
                VODNew.Config.PageBeanNewsSubmit.addNewOne(ocrFlagData);
                VODNew.Config.PageBeanNewsSubmit.sortData(VODNew.Config.SORT_RULE.desc_news_index);
                VODNew.Util.updateGridNewsSubmit();
                VODNew.Util.delNews(data.importRegId, true)
            }
        },
        hasImportData: function () {
            return $("span[name=import-id-span]").is(":visible")
        },
        doSourceRemove: function (removeArr, newSource) {
            var pageBean = VODNew.Util.createPageBean();
            pageBean.setNewData(newSource);
            var removeArrIdArr = [];
            $.each(removeArr, function (i, element) {
                if (element.isMergeMode) {
                    removeArrIdArr = removeArrIdArr.concat(element.toRemoveArr);
                } else {
                    removeArrIdArr.push(element.id);
                }
            })
            $.each(removeArrIdArr, function (i, elementId) {
                var tempData = pageBean.findData("id", elementId);
                if (tempData != null) {
                    pageBean.delOne(tempData)
                }
            })
            return pageBean.getSource();
        },


        doMaskImage: function (showImageId) {
            VODNew.MaskManager.startWork(showImageId);
        },

        loadImageOver: function (element) {
            // 1280 ,760
            var bounds = VODNew.Config.CropInstance.getBounds();
            console.log("loadImageOver", element.x, element.y, element.width, element.height);
            VODNew.Config.originalImageSize.width = bounds[0];
            VODNew.Config.originalImageSize.height = bounds[1];
            $("#ocr_image_div").css("width", bounds[0] > VODNew.Config.originalImageSize.limitWidth ? VODNew.Config.originalImageSize.limitWidth + 15 : bounds[0] + 15);
            $("#ocr_image_div").css("height", bounds[1] > VODNew.Config.originalImageSize.limitHeight ? VODNew.Config.originalImageSize.limitHeight + 15 : bounds[1] + 15);
        },
        loadImageOver3: function (element) {
            $("#demoImg").show();
            console.log("loadImageOver3", element.x, element.y, element.width, element.height);
            $("#demoImgDiv").css("width", element.naturalWidth);
            $("#demoImgDiv").css("height", element.naturalHeight)
        },
        logSubmit: function (type, params, response, plusMsg) {
            var submitLogData = {
                channelId: VODNew.Dao.getParamsData()._channel_id,
                type: type,
                descr: JSON.stringify(response) + ( plusMsg == null ? "" : "|" + plusMsg) + "|" + JSON.stringify(params) };
            VODNew.Util.doSubmitLogEntity(submitLogData);

        },
        episodeLogSubmit: function (programId, type, params, response, plusMsg) {
            var submitData = {
                programId: programId,
                type: type,
                user: auth.baseInfo.authInfo.email,
                descr: JSON.stringify(response) + ( plusMsg == null ? "" : "|" + plusMsg) + "|" + JSON.stringify(params) };
            VODNew.Util.doSubmitEpisodeLogEntity(submitData);
            if (VODNew.Config.VOD_LOG_TYPE.sendProgramDataToLego == type) {
                var tempData = {
                    success: true,
                    funcType: "create_video",
                    sendData: JSON.stringify(params),
                    plusMsg: plusMsg,
                    response: response,
                    programId: programId,
                    serverIp: VODNew.Dao.getParamsData().ip,
                    paramType: VODNew.Util.isAppendFragmentMode() ? EpgWeb.PingBack.PARAM_TYPE.append_submit : EpgWeb.PingBack.PARAM_TYPE.normal_submit
                }
                EpgWeb.PingBack.doQuickSend(tempData);
                tempData = null;
            } else if (VODNew.Config.VOD_LOG_TYPE.submitDotData == type) {
                if (VODNew.Util.isAppendFragmentMode() && 1 === params.tag) {
                    var isSuc = response != null && response.error == 0;
                    EpgWeb.PingBack.doQuickSend({
                        paramType: EpgWeb.PingBack.PARAM_TYPE.append_submit,
                        success: isSuc,
                        funcType: "submit_format",
                        sendData: JSON.stringify(params),
                        plusMsg: plusMsg,
                        response: response,
                        programId: programId,
                        serverIp: VODNew.Dao.getParamsData().ip })
                }
            }
        },
        doSubmitLogEntity: function (submitLogData) {
            VODNew.Dao.submitLogEntity(submitLogData, function (data) {
                    if (data == null || data.code != "A00000") {
                        console.warn("submitLogEntity error");
                    } else {
                        console.log("submitLogEntity suc");
                    }
                }
            )
        },
        doSubmitEpisodeLogEntity: function (submitLogData) {
            VODNew.Dao.submitEpisodeLogEntity(submitLogData, function (data) {
                    if (data == null || data.code != "A00000") {
                        console.warn("SubmitEpisodeLogEntity error");
                    } else {
                        console.log("SubmitEpisodeLogEntity suc");
                    }
                }
            )
        },
        fillDefaultTitle: function () {
            var settings = VODNew.Dao.settings;
            var c_sTime = $('input[name=eTime]').val();
            var s_sTime = $('input[name=sTime]').val();
            if (s_sTime == '' && isNaN(s_sTime)) {
                return
            }
            if (c_sTime != '' && !isNaN(c_sTime)) {
                if ($("input[name=videoName]").val().length > 0) {
                    return;
                }
                if ($('input[name=videotype]:checked').val() == -1) {
                    var show = settings.taskid + '-' + VODNew.Dao.getParamsData().channel_name + '-' + settings.today + '-' + s_sTime + '-' + c_sTime;
                    $('input[name=videoName]').val(show);
                    var ocrFirstTitle = VODNew.Util.binSearchOcrTitle(s_sTime, c_sTime).shift();
                    if (ocrFirstTitle) {
                        $("input[name=videoName]").val(ocrFirstTitle);
                        $("input[name=videoName]").attr("eut", encodeURIComponent(ocrFirstTitle));
                        $("input[name=videoName]").change()
                    }
                }
            }
        },
        doSt1Data: function (delAdStr, options, dadianmerge) {
            var global = VODNew.Config.Global;
            var paramsData = VODNew.Dao.getParamsData();
//////////////////////////制作数据统计///////////////////////////////////////////
            var sSrc = $("#img-" + options.sTime).attr("src"),
                eSrc = $("#img-" + options.eTime).attr("src");
            var s_fp_time = sSrc.substr(VODNew.Config.Global.fp_pos, 10);
            var e_fp_time = eSrc.substr(VODNew.Config.Global.fp_pos, 10);
            var seconds = (parseInt(e_fp_time) - parseInt(s_fp_time));
            options.seconds = seconds;
            $.each(global.d_sty2Data, function (n, adData) {
                var adStartTime = adData.sTime, adEndTime = adData.eTime;
                if (options.sTime < adStartTime && options.eTime > adEndTime) {

                    var sSrc = $("#img-" + adStartTime).attr("src"),
                        ads_fp_pos = sSrc.lastIndexOf('/') + 1,
                        ads_fp_time = sSrc.substr(ads_fp_pos, 10),
                        eSrc = $("#img-" + adEndTime).attr("src"),
                        ade_fp_pos = eSrc.lastIndexOf('/') + 1,
                        ade_fp_time = eSrc.substr(ade_fp_pos, 10);
                    var ad_seconds = (parseInt(ade_fp_time) - parseInt(ads_fp_time));
                    seconds = seconds - ad_seconds;
                }
            });


            VODNew.Util.dl_click("/api/st?bs=1&st=1&prid=" + options.programId
                    + "&pr_name=" + encodeURIComponent(options.title)
                    + "&pr_mins=" + seconds
                    + "&cname=" + options.cname
                    + "&u=" + VODNew.Util.getUserName()
                    + "&cp=" + paramsData._channel_name_str
                    + "&bt=" + new Date(parseInt(s_fp_time) * 1000).format("yyyy-MM-dd hh:mm:ss")
                    + "&et=" + new Date(parseInt(e_fp_time) * 1000).format("yyyy-MM-dd hh:mm:ss")
                    + "&dst=" + new Date().format("yyyy-MM-dd hh:mm:ss")
                    + "&ablum_name=" + options.album
                    + "&s_a_dot=" + ""                   //广告开始
                    + "&s_m_dot=" + options.sTime					//打点手动开始
                    + "&e_a_dot=" + ""						//广告结束
                    + "&e_m_dot=" + options.eTime					//打点手动结束
                    + "&ad_info=" + delAdStr
                    // 2017-05-02 tag dadianmerge add start
                    + "&ocr_flag=" + dadianmerge.ocr_flag
                    + "&intelligent_insert_time=" + dadianmerge.intelligent_insert_time
                    + "&ocr_title_flag=" + VODNew.Config.OCR_TITLE_FLAG
                // 2017-05-02 tag dadianmerge add end
            );
            VODNew.Config.FIRST_FRAGMENT_START = null;
            VODCom.AutoTitle.doPostEpgAutoTitleData({
                programId: options.programId,
                channelName: paramsData._channel_name_str,
                title: options.title,
                begin: new Date(parseInt(s_fp_time) * 1000).format("yyyy-MM-dd hh:mm:ss"),
                end: new Date(parseInt(e_fp_time) * 1000).format("yyyy-MM-dd hh:mm:ss")
            })
            VODNew.Util.doPostEpgOcrData(
                {
                    programId: options.programId,
                    channelName: paramsData._channel_name_str,
                    title: options.title,
                    begin: new Date(parseInt(s_fp_time) * 1000).format("yyyy-MM-dd hh:mm:ss"),
                    end: new Date(parseInt(e_fp_time) * 1000).format("yyyy-MM-dd hh:mm:ss"),
                    ocrFlag: dadianmerge.ocr_flag
                }
            );
        },
        doSt2Data: function (options) {
            var global = VODNew.Config.Global;
            var paramsData = VODNew.Dao.getParamsData();
            //////////////////////////长视频智能分析统计///////////////////////////////////////////

// sty2Data 缓存sty2数据
// d_sty2Data 缓存提交后的广告头和尾

            var headerCompleteNumbers = headerIncompleteNumbers = headerFaultNumbers = 0,
                lastCompleteNumbers = lastIncompleteNumbers = lastFaultNumbers = 0,
                adCompleteNumbers = adIncompleteNumbers = adFaultNumbers = 0;

// 计算广告智能分析正确数
            var eq_sTime, eq_eTime,
                headerSty2Index, headerSty2Length, headerListIndex,
                lastSty2Index, lastSty2Length, lastListIndex,
                gtSty2Flag, ltSty2Flag;
            var sty2DataList = global.sty2Data.list;
            if (global.channelInfo.length == 0 || global.channelInfo[0].sty2 == 1) {

                $.each(global.d_sty2Data, function (n, adData) {
                    var sVid = $('.' + adData.sTime + '-jump').attr("id").split("-")[1],
                        eVid = $('.' + adData.eTime + '-jump').attr("id").split("-")[1];
                    console.log("sty2DataList ,length ", sty2DataList.length);
                    $.each(sty2DataList, function (i, item) {
                        console.log("itemvideo_list ,length ", (item.video_list == null), item.video_list.length);
                        $.each(item.video_list, function (j, sty2Id) {
                            if (item.type == VODNew.Config.adLib) {
                                var length = item.video_list.length;
                                if (sVid == sty2Id) {
                                    headerSty2Index = i;
                                    headerListIndex = j;
                                    headerSty2Length = length;
                                    eq_sTime = sty2Id;
                                } else if (eVid == sty2Id) {
                                    lastSty2Index = i;
                                    lastListIndex = j;
                                    lastSty2Length = length;
                                    eq_eTime = sty2Id;
                                }
                                if (j == 0 && sVid < sty2Id) {
                                    ltSty2Flag = true;
                                }
                                if (j == length - 1 && eVid > sty2Id) {
                                    gtSty2Flag = true;
                                }
                            }
                        });
                    });


                    if (eq_sTime == null && eq_eTime == null) {
                        if (ltSty2Flag && gtSty2Flag) {
                            adIncompleteNumbers++;
                        } else {
                            adFaultNumbers++;
                        }

                    } else if (eq_sTime == null || eq_eTime == null) {
                        adIncompleteNumbers++;
                    } else if (eq_sTime != null && eq_eTime != null) {
                        var adRound = eq_eTime - eq_sTime + 1;
                        if (headerSty2Index == lastSty2Index && adRound == headerSty2Length) {
                            adCompleteNumbers++;
                        } else if (headerSty2Index == lastSty2Index && adRound != headerSty2Length) {

                            adIncompleteNumbers++;
                        } else if (headerSty2Index != lastSty2Index) {
                            if (headerListIndex != 0 || lastListIndex != lastSty2Length - 1) {
                                adIncompleteNumbers++;
                            } else {
                                var index = headerSty2Index;
                                var flag = true;
                                while (flag) {
                                    if (index == lastSty2Index) {
                                        adCompleteNumbers++;
                                        flag = false;
                                    } else {
                                        var videoList = sty2DataList[index].video_list;
                                        var nextVideoList = sty2DataList[index + 1].video_list;
                                        if ((nextVideoList[0] - videoList[videoList.lenth - 1]) >= 2) {
                                            adIncompleteNumbers++;
                                            flag = false;
                                        }
                                    }
                                    index++;
                                }
                            }
                        }
                    }

                });
// 广告智能分析提交数请空
                global.d_sty2Data = [];
                headerSty2Index = null;
                eq_sTime = null;
                eq_eTime = null;

                sVid = $('.' + options.sTime + '-jump').attr("id").split("-")[1];
                eVid = $('.' + options.eTime + '-jump').attr("id").split("-")[1];
// 计算片头和片尾正确数
                console.log("sty2DataList ,length ", sty2DataList.length);
                $.each(sty2DataList, function (i, item) {
                    console.log("itemvideo_list ,length ", (item.video_list == null), item.video_list.length);
                    $.each(item.video_list, function (j, sty2Id) {
                        if (item.type == VODNew.Config.adLibHead) {
                            if (sVid == sty2Id) {
                                headerSty2Index = j;
                                eq_sTime = sty2Id;
                            }
                        }
                        if (item.type == VODNew.Config.adLibTail) {
                            if (eVid == sty2Id) {
                                lastSty2Index = j;
                                lastSty2Length = item.video_list.length;
                                eq_eTime = sty2Id;
                            }
                        }
                    });
                });

                if (eq_sTime == null) {
                    headerFaultNumbers++;
                } else if (eq_sTime != null && headerSty2Index == 0) {
                    headerCompleteNumbers++;
                } else {
                    headerIncompleteNumbers++;
                }

                if (eq_eTime == null) {
                    lastFaultNumbers++;
                } else if (eq_eTime != null && lastSty2Index == lastSty2Length - 1) {
                    lastCompleteNumbers++;
                } else {
                    lastIncompleteNumbers++;
                }

                VODNew.Util.dl_click("/api/st?bs=1&st=2&channelId=" + paramsData._channel_id
                        + "&channelName=" + paramsData._channel_name_str
                        + "&channelCode=" + paramsData.channel_name
                        + "&programId=" + options.programId
                        + "&programName=" + encodeURIComponent(options.title)
                        + "&categoryName=" + options.cname
                        + "&albumName=" + options.album
                        + "&programTime=" + options.seconds
                        + "&headerCompleteNumbers=" + headerCompleteNumbers
                        + "&headerIncompleteNumbers=" + headerIncompleteNumbers
                        + "&headerFaultNumbers=" + headerFaultNumbers
                        + "&lastCompleteNumbers=" + lastCompleteNumbers
                        + "&lastIncompleteNumbers=" + lastIncompleteNumbers
                        + "&lastFaultNumbers=" + lastFaultNumbers
                        + "&adCompleteNumbers=" + adCompleteNumbers
                        + "&adIncompleteNumbers=" + adIncompleteNumbers
                        + "&adFaultNumbers=" + adFaultNumbers
                        + "&user=" + VODNew.Util.getUserName()
                );
            }
/////////////////////////////end//////////////////////////////////////////////////////
        },
        //////////////////////分片提交相关 开始//////////////////////////////////
        checkChangeFragmentMode: function () {
            var sTime = $('input[name=sTime]').val();
            if (!VODNew.Plugin.Validate.checkNum(sTime)) {
                VODNew.Plugin.tips("error", "分片的起点 必须为数字")
                return false;
            }
            var cname = $('input[name=categoryName]').val();
            var videotype = $('input[name=videotype]:checked').val();
            var title = $('input[name=videoName]').val();
            if (videotype == 0 || videotype == 1) {
                var bind_sel_name = $('input[name=videoName]').attr("bind-sel-name");
                if (bind_sel_name == null || bind_sel_name == "" || title != bind_sel_name) {
                    VODNew.Plugin.tips("error", "标题数据异常")
                    return false;
                }
            } else if (videotype == -1) {
                if (title.length == 0) {
                    VODNew.Plugin.tips("error", "标题未输入")
                    return false
                }
                var bind_sel_name = $('input[name=categoryName]').attr("bind-sel-name");
                if (bind_sel_name == null || bind_sel_name == "" || cname != bind_sel_name) {
                    VODNew.Plugin.tips("error", "频道 数据异常")
                    return false;
                }
            }
            return true;
        },

        addToDivFragment: function (currentNum) {
            if (currentNum == null) {
                currentNum = $("#div_fragment_append").children().length + 1;
            }
            if (currentNum == 2) {
                $('input[name=isAppendFragment]').attr("disabled", "disabled");
            }
            var htmlArr = [];
            htmlArr.push('<div fragment-line="0" >');
            htmlArr.push(' 分片起点：<input type="text" class="form-control input-sm" style="width:55px" readonly="true" > &nbsp; &nbsp;');
            htmlArr.push(' 分片终点：<input type="text"  class="form-control input-sm" style="width:55px">');
            htmlArr.push('  <button type="button" name="btn_preview_fragment" class="btn btn-primary ">预览分片</button>');
            htmlArr.push('  <button type="button" name="btn_submit_fragment" class="btn btn-primary ">提交分片</button>');
            htmlArr.push('  </div>');
            var divTarget = $(htmlArr.join(""));
            divTarget.attr("fragment-line", currentNum);
            if (currentNum == 1) {
                divTarget.find("input:eq(0)").val($('input[name=sTime]').val());
                divTarget.appendTo($("#div_fragment_append"));
            } else {
                var preDivTarget = $("div[fragment-line=" + (currentNum - 1) + "]");
                var etVal = preDivTarget.find("input:eq(1)").val();
                if (!VODNew.Plugin.Validate.checkNum(etVal)) {
                    return;
                }
                var stVal = parseInt(preDivTarget.find("input:eq(0)").val());
                if (stVal >= etVal) {
                    return;
                }
                preDivTarget.find("input:eq(1)").attr("readonly", true);
                divTarget.find("input:eq(0)").val(parseInt(etVal) + 1);
                divTarget.appendTo($("#div_fragment_append"));
            }
        },
        doQuickFragmentSubmit: function () {
            var childLength = $("#div_fragment_append").children().length;
            if (childLength == 1) {
                return;
            }
            var parentDiv = $("div[fragment-line='" + (childLength - 1) + "']");
            VODNew.Util.handlerRemoveFgRemindBlock();
            VODNew.Util.doFragmentSubmit(parentDiv, {
                doSuc: function () {
                    console.log("doQuickFragmentSubmit suc ")
                },
                doError: function () {
                    console.log("doQuickFragmentSubmit error ")
                },
                doRevert: function () {
                    console.log("doQuickFragmentSubmit doRevert ")
                }
            })
        },
        doShortcutFragmentSubmit: function () {
            if ($("#fragment-dlg").is(":visible")) {
                return;
            }
            var btn = $("button[name=btn_submit_fragment]:visible");
            if (btn.length == 1) {
                btn.click();
            }
        },
        doShortcutSetFragmentEnd: function () {
            if ($("#fragment-dlg").is(":visible")) {
                return;
            }
            var btn = $("button[name=btn_submit_fragment]:visible");
            if (btn.length != 1) {
                VODNew.Plugin.tips("error", "尚未启用分片！");
                return;
            }
            btn.parent().find("input:eq(1)").val($.trim($(".red").parent().find(".pid").html()));
        },
        doFragmentSubmit: function (parentDiv, callhandler) {
            var settings = VODNew.Dao.settings;
            var paramsData = VODNew.Dao.getParamsData();
            if (settings.taskid < 1.) {
                callhandler.doError('任务ID为空,不能提交!');
                return;
            }
            if ($("span[span-mode=warn]").is(":visible")) {
                callhandler.doError('标题过长,不能提交!');
                return;
            }
            $('input[name=imageId]').val($('input[name=imageId]').val().trim());

            var sTime = $("#cForm").find("input[name=sTime]").val()
            var eTime = parentDiv.find("input:eq(1)").val();
            var pic = sTime;
            var fantasyTitle = $('input[name=fantasyTitle]').val() ? $('input[name=fantasyTitle]').val() : "";
            var title = $('input[name=videoName]').val(),
                channel = $('input[name=categoryName]').suggest("getValue");
            var data = {
                '起始帧': sTime,
                '结束帧': eTime,
                '标题': title,
                '频道': channel
            }
            var album = $('input[name=albumName]').val();
            var cpOption = $('#cp').children('option:selected');
            var priority = $('input[name=priority]:checked').val(), //优先级
                video_dpi = $('input[name=video_dpi]:checked').val(), //分辨率
                isVolumeStandard = $('input[name=isVolumeStandard]:checked').val(), //节目音量标准化参数
                isVolumeStandardForMaterial = $('input[name=isVolumeStandardForMaterial]:checked').val(), //素材音量标准化参数
                uid = cpOption.attr("uid"), //表示ugc用户id
                partnerId = cpOption.attr("partnerId"), //表示合作方id
                episodeType = cpOption.attr("episodeType"); //取值为0或1,1表示为ugc视频，0为普通ppc视频
            uid = !uid ? "" : uid;
            partnerId = !partnerId ? "" : partnerId;
            episodeType = !episodeType ? "" : episodeType;
            var albumId = '';
            if (album) {
                albumId = $('input[name=albumName]').suggest("getValue") || "";
            }
            if (!this.checkStAndEt(sTime, eTime)) {
                callhandler.doError("开始结束时间错误", true);
                return;
            }
            var checkArr = [];
            var numTime = $('#picNum').text();
            checkArr.push({value: parseInt(eTime), error: "结束帧不存在,不能提交", type: "lt", other: parseInt(numTime)  })
            if (!VODNew.Plugin.Validate.batchCheck(checkArr)) {
                callhandler.doError("interrupt checkLiveType checkRepeat", true);
                return;
            }
            $('#addInfo').attr('disabled', 'disabled');
            if (!this.validAddInfo(data)) {
                callhandler.doError("validAddInfo 失败", true);
                return;
            }
            VODCom.Player.splitData(sTime, eTime, true);
            if (!settings.subData.length) {
                //alert('该条打了删除，不能再打拆条!');
                callhandler.doError('该条打了删除，不能再打拆条!');
                return;
            }
            var p_vid = $('input[name=videoName]').suggest("getValue") || 0;
            var p_albumId = $('input[name=albumName]').suggest("getValue") || "";
            var videotype = $('input[name=videotype]:checked').val();
            if (videotype == -1) {
                p_vid = 0
            }
            var dataJson = {
                'videoId': p_vid,
                'priority': priority,
                'albumName': album,
                'videoName': title,
                'categoryId': channel,
                'albumId': p_albumId,
                'reTranscodeConfirm': VODNew.Util.getReTranscodeConfirmVal(),
                'freeType': paramsData.freeType,
                'isVolumeStandard': isVolumeStandard,
                isVolumeStandardForMaterial: isVolumeStandardForMaterial,
                userArea: VODNew.Util.getUserRegion()
            };
            if ($("#locationDiv").is(":visible")) {
                dataJson.locationCategory = $("input[name=location]").suggest("getValue");
            }
            if (videotype == -1) {
                dataJson.fantasyTitle = fantasyTitle;
            }

            var newPA = {
                title: title,
                cat: channel,
                alb: albumId,
                enableClound: VODNew.Util.getEnableCloundVal(),
                priority: priority,
                video_dpi: video_dpi,
                uid: uid,
                partnerId: partnerId,
                episodeType: episodeType
            }
            if (videotype == -1) {
                newPA.fantasyTitle = fantasyTitle;
            } else if (videotype == 1) {
                newPA.reTranscodeConfirm = VODNew.Util.getReTranscodeConfirmVal();
            }
            var dealRoute = -1;
            if (VODNew.Config.lastLegoSubmitObj.programId != VODNew.Config.fragmentPid) {
                VODNew.Config.lastLegoSubmitObj.programId = VODNew.Config.fragmentPid;
                VODNew.Config.lastLegoSubmitObj.hasSubmit = false;
                dealRoute = 1;
            } else if (VODNew.Config.lastLegoSubmitObj.hasSubmit == false) {
                dealRoute = 2;
            } else {
                dealRoute = 3;
            }
            if (VODNew.Config.FIRST_FRAGMENT_START == null) {
                VODNew.Config.FIRST_FRAGMENT_START = this.formatDateTimeFormat(new Date());
            }
            if (dealRoute == 1 || dealRoute == 2) {
                var sendData = {"request": JSON.stringify({url: VODNew.Constant.thirdUrl_peditor_submit, type: "post", params: {
                    data: JSON.stringify(dataJson)
                }, needCookie: true}), timeSign: new Date().getTime()}
                VODNew.Dao.dopeditorSubmit(sendData, {
                    doSuc: function (res) {
                        if (res == null || res.code != 'A00000') {
                            VODNew.Util.logSubmit(VODNew.Config.VOD_LOG_TYPE.sendProgramDataToLego, sendData, res, "fromUrl:" + VODNew.Constant.thirdUrl_peditor_submit);
                            VODNew.Plugin.tips("error", res == null ? "lego接口无效返回值" : "lego错误：" + res.msg);
                            callhandler.doRevert();
                        } else {
                            var programId = res.data.programId;
                            if (!programId) {
                                VODNew.Util.logSubmit(VODNew.Config.VOD_LOG_TYPE.sendProgramDataToLego, sendData, {error: '乐高返回的programId为空!'}, "fromUrl:" + VODNew.Constant.thirdUrl_peditor_submit);
                                callhandler.doError('乐高返回的programId为空!');
                                return;
                            }
                            VODNew.Util.episodeLogSubmit(programId, VODNew.Config.VOD_LOG_TYPE.sendProgramDataToLego, sendData, res, "fromUrl:" + VODNew.Constant.thirdUrl_peditor_submit);
                            VODNew.Config.fragmentPid = programId;
                            VODNew.Config.lastLegoSubmitObj.programId = VODNew.Config.fragmentPid;
                            VODNew.Config.lastLegoSubmitObj.hasSubmit = true;
                            //提交数据给刘之红
                            VODNew.Util.postFragmentData(settings.subData, newPA, pic, VODNew.Config.fragmentPid, callhandler)
                        }
                    },
                    doError: function (XMLHttpRequest, status) {
                        VODNew.Util.logSubmit(VODNew.Config.VOD_LOG_TYPE.sendProgramDataToLego, sendData, { type: "error reqeust", status: status }, "fromUrl:" + VODNew.Constant.thirdUrl_peditor_submit);
                        callhandler.doError('网络错误,请稍后再提交！');
                        return;
                        //              VODNew.Plugin.tips("error", '接口/peditor/submit调用超时10秒未响应！请联系乐高相关负责人员！');
                    }
                })
            } else if (dealRoute == 3) {
                //提交数据给刘之红
                VODNew.Util.postFragmentData(settings.subData, newPA, pic, VODNew.Config.fragmentPid, callhandler)
            }

        },
        transToFragmentMode: function () {
            $('input[name=videotype]').attr("disabled", "disabled");
            $('input[name=sTime]').attr("readonly", true);
            $('input[name=categoryName]').attr("disabled", "disabled");
            $('input[name=videoName]').attr("readonly", true);
            $('input[name=albumName]').attr("readonly", true);
            $('input[name=location]').attr("readonly", true);
            $("#cp").attr("readonly", true);

            $('input[name=priority]').attr("disabled", "disabled")
            $('input[name=video_dpi]').attr("disabled", "disabled")
            $('input[name=isVolumeStandard]').attr("disabled", "disabled");
            $('input[name=needRemakeVideo]').attr("disabled", "disabled");
            $('input[name=isVolumeStandardForMaterial]').attr("disabled", "disabled");

            $('input[name=reTranscodeConfirm]').attr("disabled", "disabled");
            $("#div_fragment_append").html("");
            $("#div_fragment_append").show();
            VODNew.Util.handlerChangeFgRemindStart()
            VODNew.Util.addToDivFragment(1);

        },

        transToNormalMode: function () {
            VODNew.Config.fgRemindObj.stop = true;
            $('input[name=videotype]').removeAttr("disabled");
            $('input[name=sTime]').removeAttr("readonly");
            $('input[name=videoName]').removeAttr("readonly");
            $('input[name=albumName]').removeAttr("readonly");
            $('input[name=location]').removeAttr("readonly");
            $("#cp").removeAttr("readonly");
            $('input[name=priority]').removeAttr("disabled");
            $('input[name=video_dpi]').removeAttr("disabled");
            $('input[name=isVolumeStandard]').removeAttr("disabled");
            $('input[name=needRemakeVideo]').removeAttr("disabled");
            $('input[name=isVolumeStandardForMaterial]').removeAttr("disabled");
            $('input[name=isAppendFragment]').removeAttr("disabled");
            $('input[name=reTranscodeConfirm]').removeAttr("disabled");
            var videotype = $('input[name=videotype]:checked').val();
            if (videotype == -1) {
                $('input[name=categoryName]').removeAttr("disabled");
            }
            $("#div_fragment_append").hide();
        },
        postFragmentData: function (list, newPA, imageId, programId, callhandler) {
            var sList = '[' + list.join(",") + "]";
            var paramsData = VODNew.Dao.getParamsData();
            var settings = VODNew.Dao.settings;
            var dotData = VODNew.Dao.getDotData();
            var accurateFrame = VODNew.AccurateFrame.getAccurateFrame()
            var pData = {
                tag: 0,
                'title': newPA.title,
                'categoryId': newPA.cat,
                'albumId': newPA.alb,
                'code': paramsData.channel_name,
                'programId': programId,
                'userId': VODNew.Util.getUserId() + "",
                'from_client': true,
                'key': settings.taskid,
                'list': sList,
                'imageId': imageId,
                'head': accurateFrame.head,
                'end': "",
                'priority': newPA.priority,
                'video_dpi': newPA.video_dpi,
                'uid': newPA.uid,
                'partnerId': newPA.partnerId,
                'episodeType': newPA.episodeType,
                'enableClound': newPA.enableClound,
                'needRemakeVideo': VODNew.Util.getNeedRemakeVideo(),
                'delogoArr': JSON.stringify(VODNew.Util.fetchDelogoArr(list))
            };
            if ("fantasyTitle" in newPA) {
                pData.fantasyTitle = newPA.fantasyTitle;
            }
            if ("reTranscodeConfirm" in newPA) {
                if (VODNew.Config.lastSubmitObj.programId != programId || VODNew.Config.lastSubmitObj.hasSubmit == false) {
                    VODNew.Config.lastSubmitObj.programId = programId;
                    VODNew.Config.lastSubmitObj.hasSubmit = true;
                    pData.reTranscodeConfirm = newPA.reTranscodeConfirm;
                }
            }

            VODNew.Dao.postSync(dotData.appendUrl, pData, {
                doSuc: function (data) {
                    console.log(" 日志:" + JSON.stringify(pData))
                    //        VODNew.Util.logSubmit(VODNew.Config.VOD_LOG_TYPE.submitFragmentData, pData, data, "url:" + dotData.appendUrl);
                    VODNew.Util.episodeLogSubmit(programId, VODNew.Config.VOD_LOG_TYPE.submitFragmentData, pData, data, "url:" + dotData.appendUrl);
                    if (data.error != 0) {
                        callhandler.doError(data.error);
                    } else {
                        callhandler.doSuc();
                        VODNew.Plugin.tips("success", '提交分片成功');
                    }
                },
                doError: function () {
                    VODNew.Util.episodeLogSubmit(programId, VODNew.Config.VOD_LOG_TYPE.submitFragmentData, pData, {type: "request error"}, "url:" + dotData.appendUrl);
                    //       VODNew.Util.logSubmit(VODNew.Config.VOD_LOG_TYPE.submitFragmentData, pData, {type: "request error"}, "url:" + dotData.appendUrl);
                    callhandler.doError('编码服务器网络错误,请稍后再提交！');
                }
            }, false)
        },
        isAppendFragmentMode: function () {
            return $("input[name=isAppendFragment][value='1']").is(":checked")
        },
        checkFragmentEnd: function (eTime) {
            var childLength = $("#div_fragment_append").children().length;
            if (childLength == 1) {
                return true;
            }
            var fragmentEnd = $("div[fragment-line='" + (childLength - 1) + "']").find("input:eq(1)").val();
            if (parseInt(fragmentEnd) > parseInt(eTime)) {
                VODNew.Plugin.tips("error", "结尾帧不能小于分片结尾帧！");
                return false;
            }
            return true;
        },
        autoFillFragmentEnd: function () {
            var autoEnd = parseInt($("#fragment-dlg").find("span:eq(1)").html());
            var childLength = $("#div_fragment_append").children().length;
            $("div[fragment-line='" + childLength + "']").find("input:eq(1)").val(autoEnd);
            VODNew.Config.AUTO_SUBMIT_TRIGGER = true;
            $("div[fragment-line='" + childLength + "']").find("button[name=btn_submit_fragment]").click();
        },
        handlerRemoveFgRemindBlock: function () {
            VODNew.Config.fgRemindObj.lastTime = Date.now() + 100;
            VODNew.Config.fgRemindObj.block = false;
        },
        handlerChangeFgRemindStart: function () {
            VODNew.Config.fgRemindObj.lastTime = Date.now() + 100;
            VODNew.Config.fgRemindObj.stop = false;
        },
        //////////////////////分片提交相关 结束//////////////////////////////////

        //广告，打点片段 联动相关 开始///////////////////////
        checkAdvertAffectDot: function (st, et) {
            var childLength = $("#div_fragment_append").children().length;
            if (childLength > 1) {
                var sTime = $("#cForm").find("input[name=sTime]").val()
                var fragmentEnd = $("div[fragment-line='" + (childLength - 1) + "']").find("input:eq(1)").val();
                var intValue_d_sTime = parseInt(st);
                var intValue_d_eTime = parseInt(et);
                var intValue_sTime = parseInt(sTime);
                var intValue_fragmentEnd = parseInt(fragmentEnd);
                if (( intValue_d_sTime <= intValue_fragmentEnd && intValue_d_sTime >= intValue_sTime ) ||
                    ( intValue_d_eTime <= intValue_fragmentEnd && intValue_d_eTime >= intValue_sTime )) {
                    return true;
                }
            }
            return false
        },
        //广告，打点片段 联动相关 结束///////////////////////
        doPostEpgOcrData: function (baseObj) {
            if (VODNew.Config.OCR_TITLE_FLAG == 1) {
                var sendData = VODNew.Util.prepareOcr2Data(baseObj);
                VODNew.Dao.postOcr2Data({data: JSON.stringify(sendData) }, function (data) {
                    if (data != null && data.code == "A00000") {
                        VODNew.Plugin.tips("success", '投递epg ocr 数据成功');
                    } else {
                        VODNew.Plugin.tips("error", '投递epg ocr 数据失败');
                    }
                });
            }
            VODNew.Config.OCR_TITLE_FLAG = 0;
            VODNew.Config.OCR_TITLE_ORIGIN = null;
        },
        prepareOcr2Data: function (baseObj) {
            var data = {
                channelName: baseObj.channelName,
                ocrTitle: VODNew.Config.OCR_TITLE_ORIGIN.trim(),
                ocrTitleCharLen: 0,
                addTime: VODNew.Util.formatDateTimeFormat(new Date()),
                liveBeginTime: baseObj.begin,
                liveEndTime: baseObj.end,
                ocrFlag: baseObj.ocrFlag,
                user: VODNew.Util.getUserName(),
                imageUrl: $("#ocr_image").attr("src"),
                locations: $("input[name=image_location]").val(),
                userTitle: baseObj.title.trim(),
                userTitleCharLen: 0,
                legoProgramId: baseObj.programId,
                percent: 0
            };
            data.ocrTitleCharLen = Com.string.getStrLength(data.ocrTitle);
            data.userTitleCharLen = Com.string.getStrLength(baseObj.title);
            data.percent = VODCom.OCR.accountOcrPercent(data.ocrTitle, data.userTitle);
            return data;
        },

        updateGridMaskEntityRow: function (object) {
            if (object != null) {
                var findData = VODNew.Config.PageBeanMaskEntity.findData("index", object.index);
                for (var key in object) {
                    if (key != "index" && findData.hasOwnProperty(key)) {
                        findData[key] = object[key];
                    }
                }
                $('#mask_list').setRowData(object.index, object);
            }
        },
        notifyAlert: function (msg) {
            var sendData = {};
            sendData.user = auth.dev() ? VODNew.Config.ALERT_USER.TEST_SEND : VODNew.Config.ALERT_USER.PRO_SEND;
            sendData.content = msg;
            //     sendData.email_subject可以自定义邮件标题
            sendData.notifyType = VODNew.Config.ALERT_PLATFORM_NOTIFY.SEND_CHAT;
            EpgWeb.Util.notifyAlert(sendData, function (rdata) {
                console.log("notifyAlert:" + JSON.stringify(rdata))
            })
        },
        checkAdvertSupport: function () {
            VODNew.Dao.doAdvertTest(function (returnData) {
                if (returnData != null) {
                    if (returnData.statusText == "error") {
                        return;
                    }
                    VODNew.Config.ADVERT_SUPPORT = true;
                }
            });
        },
        //灰度上线
        checkGreyMode: function () {
            if (VODNew.Config.GREY_MODE.containsObj({ip: VODNew.Dao.getParamsData().ip, cn: VODNew.Dao.getParamsData()._channel_name_str})) {
                $("button[name=btn_get_auto_title]").show();
                VODNew.Config.HELP_DATA.push(VODNew.Config.HELP_DATA_AUTO_TITLE[0] );
            } else {
                $("button[name=btn_get_auto_title]").hide();
            }
        },
        getUserRegion: function () {
            var retRegion = "";
            var region = auth.baseInfo.authInfo.region;
            var checkArr = ["","bj","sh","cq","tw"];
            if(region > 0 && region <  checkArr.length ){
                retRegion = checkArr[region];
            }else{
                return "";
            }
            return retRegion
        },
        getNeedRemakeVideo: function () {
            return  parseInt($('input[name=needRemakeVideo]:checked').val());
        }
    })
})
;